﻿/********************************************************************************
     File:																
            Default.aspx.cs                         
     Description:
列表
     Author:									
            DDBuildTools
            http://DDBuildTools.supesoft.com
     Finish DateTime:
			2011-10-15 22:58:27
     History:
*********************************************************************************/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

using repproblem;
using repproblem.Components;
using FrameWork;
using FrameWork.Components;


namespace repproblem.Web.Module.repproblem.its_RepProblem
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindDataList();
            }
        }

        /// <summary>
        /// 绑定数据
        /// </summary>
        private void BindDataList()
        {
            QueryParam qp = new QueryParam();
            qp.Where = SearchTerms;
            qp.PageIndex = AspNetPager1.CurrentPageIndex;
            qp.PageSize = AspNetPager1.PageSize;
            int RecordCount = 0;
            List<its_RepProblemEntity> lst = BusinessFacaderepproblem.its_RepProblemList(qp, out RecordCount);
            GridView1.DataSource = lst;
            GridView1.DataBind();
            this.AspNetPager1.RecordCount = RecordCount;
        }

        /// <summary>
        /// 点击分页事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindDataList();
        }

        /// <summary>
        /// 查询条件
        /// </summary>
        private string SearchTerms
        {
            get
            {
                if (ViewState["SearchTerms"] == null)
                    ViewState["SearchTerms"] = " Where 1=1 ";
                return (string)ViewState["SearchTerms"];
            }
            set { ViewState["SearchTerms"] = value; }
        }

        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            string ServRepProb_Value = (string)Common.sink(ServRepProb.UniqueID, MethodType.Post, 4, 0, DataType.Str);
            string Context_Value = (string)Common.sink(Context.UniqueID, MethodType.Post, 500, 0, DataType.Str);
            string ServTrobTypeId_Value = (string)Common.sink(ServTrobTypeId.UniqueID, MethodType.Post, 4, 0, DataType.Str);
            string ServProbTypeId_Value = (string)Common.sink(ServProbTypeId.UniqueID, MethodType.Post, 4, 0, DataType.Str);
            string ResolventId_Value = (string)Common.sink(ResolventId.UniqueID, MethodType.Post, 4, 0, DataType.Str);
            StringBuilder sb = new StringBuilder();
            sb.Append(" Where 1=1 ");
            
            if (ServRepProb_Value != string.Empty)
            {
                sb.AppendFormat(" AND ServRepProb = {0} ", Convert.ToInt32(ServRepProb_Value));
            }
            
            if (Context_Value != string.Empty)
            {
                sb.AppendFormat(" AND Context like '%{0}%' ", Common.inSQL(Context_Value));
            }
            
            if (ServTrobTypeId_Value != string.Empty)
            {
                sb.AppendFormat(" AND ServTrobTypeId = {0} ", Convert.ToInt32(ServTrobTypeId_Value));
            }
            
            if (ServProbTypeId_Value != string.Empty)
            {
                sb.AppendFormat(" AND ServProbTypeId = {0} ", Convert.ToInt32(ServProbTypeId_Value));
            }
            
            if (ResolventId_Value != string.Empty)
            {
                sb.AppendFormat(" AND ResolventId = {0} ", Convert.ToInt32(ResolventId_Value));
            }
            ViewState["SearchTerms"] = sb.ToString();
            BindDataList();
            TabOptionWebControls1.SelectIndex = 0;
        }
    }
}
